International Text (IText)
This section describes the utilities defined in the files IText.h and IText.cpp. These utilities create, destroy, and manipulate international text (ODIText
) structures, which contain a variable-size text buffer as well as Mac OS script and language codes.Creation in Default Heap
The following functions create anODIText
structure using a C string. On the Mac OS, theODScriptCode
and theODLangCode
parameters correspond to the platform script code and language code. TheCreateIText
function is overloaded to use different types of input parameters, as shown throughout this section.
ODIText* CreateITextCString(ODScriptCode script, ODLangCode lang, char* text); ODIText* CreateIText(ODScriptCode script, ODLangCode lang, char* text);The following functions create anODIText
structure using a Pascal string:
ODIText* CreateITextPString(ODScriptCode script, ODLangCode lang, StringPtr text); ODIText* CreateIText(ODScriptCode script, ODLangCode lang, StringPtr text);The following functions create anODIText
structure with an empty string of specified length:
ODIText* CreateITextClear(ODScriptCode script, ODLangCode lang, ODSize stringLength ); ODIText* CreateIText(ODScriptCode script, ODLangCode lang, ODSize stringLength );The following functions create anODIText
structure with a buffer of characters of specified length:
ODIText* CreateITextWLen(ODScriptCode script, ODLangCode lang, ODUByte* text, ODSize textLength ); ODIText* CreateIText(ODScriptCode script, ODLangCode lang, ODUByte* text, ODSize textLength)The following function sets the buffer size of theODIText
structure. If the inputODIText
pointer iskODNULL
, this function is equivalent to theCreateITextClear
function.
ODIText* SetITextBufferSize(ODIText* text, ODSize bufferSize, ODBoolean preserveContents );Destruction
The following function disposes of anODIText
structure and any memory associated with it:
void DisposeIText(ODIText* text);The following function is the same as theDisposeIText
function except that it works onODIText
structure allocated on the stack:
void DisposeITextStruct(ODIText text);Duplication
The following function allocates and returns an exact copy of theODIText
structure passed in:
ODIText* CopyIText(ODIText* original);The following function is the same as theCopyIText
function except that the returnedODIText
structure is allocated on the stack:
ODIText CopyITextStruct(ODIText* original);Accessing Attributes
The following functions set and get the script code of theODIText
structure passed in:
void SetITextScriptCode(ODIText* text, ODScriptCode script); ODScriptCode GetITextScriptCode(ODIText* text);The following functions set and get the language code of theODIText
structure passed in:
void SetITextLangCode(ODIText* text, ODLangCode lang); ODLangCode GetITextLangCode(ODIText* text);The following function sets the length of theODIText
structure's string length field. IfkODNULL
is passed in as the inputODIText
, the function is equivalent to theCreateITextClear
function.
ODIText* SetITextStringLength( ODIText* text, ODSize length, ODBoolean preserveText); ODIText* CreateIText(ODSize length);The following function returns the string length of theODIText
structure passed in:
ODULong GetITextStringLength(ODIText* text);Accessing the String
The following function returns a pointer to the raw text without allocating any memory.
- IMPORTANT
- This function should be used with extreme caution because the pointer returned belongs to the
ODIText
structure.
char* GetITextPtr(ODIText* text);The following functions set the string of theODIText
structure with a C string. Note that theSetITextString
function is overloaded and can also take a Pascal string:
void SetITextCString(ODIText* iText, char* cString); void SetITextString(ODIText* iText, char* cString); The following functions set the string of the ODIText structure with a Pascal string. void SetITextPString(ODIText* iText, StringPtr pString); void SetITextString(ODIText* iText, StringPtr pString); The following function sets the string of the ODIText structure with a buffer of the specified length: void SetITextText(ODIText* text, ODUByte* text, ODSize textLength);The following functions return to a C string a pointer that corresponds to the string in theODIText
structure. If a string is passed in, the same string is used to return the result. Otherwise, this function allocates memory for the returned string. Note that theGetITextString
function is overloaded and can also take and return a Pascal string.
char* GetITextCString(ODIText* iText, char* cString); char* GetITextString(ODIText* iText, char* cString); char* GetCStringFromIText(ODIText* iText);The following functions work like theGetITextCString
function except that they return a Pascal string:
StringPtr GetITextPString(ODIText*, Str255 pString); StringPtr GetITextString(ODIText* i, StringPtr pString); StringPtr GetPStringFromIText(ODIText* iText);
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help